import Axios from "axios";
import Qs from 'qs'
export default {
    /**
     * 获取任务列表
     */
    getTaskPageList: function ({ currentPage , pageSize , status , name, startdate, enddate }) {
    const params={
    pageNum : currentPage,
    pageSize : pageSize,
    status : status,
    name : name,
    startDate : startdate,
    endDate : enddate
    };
       return Axios.post('/crawler/api/task/getTaskPageList', Qs.stringify(params),{headers: {'Content-Type': 'application/x-www-form-urlencoded'}});
    },
    updateTask : function (params){
       return Axios.post('/crawler/api/task/updateTask', params);
    },
    deleteTask : function ({taskId}){
    const params ={
     taskId : taskId
    };
        return Axios.post('/crawler/api/task/deleteTask', Qs.stringify(params),{headers: {'Content-Type': 'application/x-www-form-urlencoded'}});
    },
    addTask : function (params) {
        return Axios.post('/crawler/api/task/addTask', params);
    },
    startTask : function ({taskId}) {
      const params ={
        taskId : taskId
      };
        return Axios.post('/crawler/api/crawler/start', Qs.stringify(params),{headers: {'Content-Type': 'application/x-www-form-urlencoded'}});
    },
    stopTask : function ({taskId}) {
    const params ={
      taskId : taskId
    };
    return Axios.post('/crawler/api/crawler/stop', Qs.stringify(params),{headers: {'Content-Type': 'application/x-www-form-urlencoded'}});
  }

}
